package com.easylinkin.linkappapi.device.constant;

/**
 * <p>
 * 告警管理常量
 * </p>
 *
 * @author TongJie
 * @since 2020/4/30 15:01
 */
public interface DeviceConstant {

  /**
   * 设备状态,0:离线; 1:在线
   */
  enum DeviceOnlineStatusEnum {
    /**
     * 设备在线状态： 在线
     */
    ON_LINE(1, "在线"),
    /**
     * 设备在线状态： 离线
     */
    OFF_LINE(0, "离线");

    private final Integer type;

    private final String description;

    DeviceOnlineStatusEnum(Integer type, String description) {
      this.type = type;
      this.description = description;
    }

    public Integer getType() {
      return type;
    }

    public String getDescription() {
      return description;
    }
  }


  /**
   * 设备状态,0:正常; 1:告警
   */
  enum DeviceStatusEnum {
    /**
     * 设备状态：正常
     */
    NORMAL(0, "正常"),
    /**
     * 设备状态：告警
     */
    ALARM(1, "告警");

    private final Integer type;

    private final String description;

    DeviceStatusEnum(Integer type, String description) {
      this.type = type;
      this.description = description;
    }

    public Integer getType() {
      return type;
    }

    public String getDescription() {
      return description;
    }
  }

  /**
   * 处理状态
   */
  enum StatisticsTimeTypeEnum {

    /**
     * "%Y-%m-%d" 根据天
     */
    DAY("%Y-%m-%d", "按天"),
    /**
     * "%Y-%m" 根据月
     */
    MONTH("%Y-%m", "按月"),

    /**
     * '%Y-%u'根据周
     */
    WEEK("%Y-%u", "按周"),
    /**
     * '%Y-%u'根据年
     */
    YEAR("%Y", "按年");


    private final String type;
    private final String description;

    StatisticsTimeTypeEnum(String type, String description) {
      this.type = type;
      this.description = description;
    }

    public String getType() {
      return type;
    }

    public String getDescription() {
      return description;
    }

  }

  /**
   * 设备工作状态,1:初始化;2:工作;3:维保
   */
  enum DeviceWorkStatusEnum {
    /**
     * 设备工作状态,1:初始化
     */
    INIT(1, "初始化"),
    /**
     * 设备工作状态,2:工作
     */
    WORK(2, "工作"),
    /**
     * 设备工作状态,3:维保
     */
    MAINTAIN(3, "维保");

    private final Integer type;

    private final String description;

    DeviceWorkStatusEnum(Integer type, String description) {
      this.type = type;
      this.description = description;
    }

    public Integer getType() {
      return type;
    }

    public String getDescription() {
      return description;
    }
  }


  /**
   * 模型设备型号类别
   */
  enum ModelCategoryEnum {
    /**
     * 喷淋设备型号列表标识
     */
    SPARY("spary", "喷淋设备型号列表标识", "SPARY_DEVICE_TYPE_NAMES"),
    /**
     * 用水设备型号列表标识
     */
    WATTER("water", "用水设备型号列表标识", "WATER_DEVICE_TYPE_NAMES"),
    /**
     * 扬尘设备型号列表标识
     */
    RAISE_DUST("raise_dust", "扬尘设备型号列表标识", "RAISE_DUST_DEVICE_TYPE_NAMES"),
    /**
     * 用电设备型号列表标识
     */
    ELECTRICY("electricy", "用电设备型号列表标识", "ELECTRICY_DEVICE_TYPE_NAMES"),
    /**
     * 配电箱设备型号列表标识
     */
    ELECTRIC_BOX("electric_box", "配电箱设备型号列表标识", "DQHZ_DEVICE_TYPE_NAMES"),
    /**
     *断路器设备型号列表标识
     */
    CIRCUIT_GIVEALARM("circuit_givealarm","断路器设备型号列表标识","DLQ-RS485-16-0123"),
    /**
     * 电气火灾设备型号标识
     */
    DQHZ_SBXHBS("electric_fire","电气火灾设备型号标识","DQHZ-NBAA-01-0012");


    private final String type;

    private final String description;

    private final String deviceTypeNameKey;

    ModelCategoryEnum(String type, String description, String deviceTypeNameKey) {
      this.type = type;
      this.description = description;
      this.deviceTypeNameKey = deviceTypeNameKey;
    }

    public String getType() {
      return type;
    }

    public String getDescription() {
      return description;
    }

    public String getDeviceTypeNameKey() {
      return deviceTypeNameKey;
    }

  }

  /**
   * 时间粒度
   */
  interface GrainSize{
    Byte DAY = 0;
    Byte WEEK = 1;
    Byte MONTH = 2;
  }

  /**
   * 设备打点使用位置
   */
  enum PositionUsePlace {
    /**
     * 环境管理（大屏）
     */
    ENVIRONMENT("ENVIRONMENT");
    private String value;

    PositionUsePlace(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }
  }

  /**
   * 铁路设备类型枚举
   */
  enum RailwayDeviceType {
    VIDEO_MONITOR(1, "视频监控", 1),
    WEATHER_STATION(2, "气象站", null),
    HIGH_MOULD_MONITOR(3, "高支模监测", null),
    CONCRETE_TEMPERATURE_CONTROLLER(4, "混凝土温控", null),
    TRANSVERSE_BRIDGE_MONITOR(5, "转体桥监测", null),
    HAND_TERMINAL(6, "手持终端", null),
    BEIDOU_LOCATION(7, "北斗定位", 2),
    DRIVER_BEHAVIOR_RECOGNITION(8, "司机行为识别", 3),
    AI_RECOGNITION_HOST(9, "AI识别主机", 3),
    CRANE_TRUCK_MONITOR(10, "吊车监测", 1),
    TANK_MONITOR(11, "塔吊监测", 1),
    TEMPERATURE_HUMIDITY_SENSOR(12, "温湿度传感器", null),
    WIFI_SMOKE_DETECTOR(13, "无线烟感传感器", null),
    ELECTRIC_FIRE(14, "电气火灾", null),
    DEEP_CREEK_MONITOR(15, "深基坑监测", null),
    BUSINESS_LINE_MONITOR(16, "营业线监测", null),
    REAL_TIME_BROADCAST(17, "现场广播", null),
    SMART_SECURITY_HAT(18, "智能安全帽", null),
    VIDEO_ELEVATION_FENCE(19, "视频电子围栏", null),
    ELECTRIC_METER(20, "电表", null),
    CIRCUIT_BREAKER(21, "断路器", null);
    /**
     * 设备类型
     */
    private Integer type;
    /**
     * 设备类型描述
     */
    private String description;
    /**
     * 关联设备类型 1 主机 2 定位设备 3 视频监控设备 4 其他
     */
    private Integer railDeviceTypeId;

    RailwayDeviceType(Integer type, String description, Integer railDeviceTypeId) {
      this.type = type;
      this.description = description;
      this.railDeviceTypeId = railDeviceTypeId;
    }

    public static String getNameByTypeId(Integer railDeviceType) {
      for (RailwayDeviceType deviceType : RailwayDeviceType.values()) {
        if (deviceType.getType().equals(railDeviceType)) {
          return deviceType.getDescription();
        }
      }
      return null;
    }

    public static RailwayDeviceType getRailwayDeviceTypeByTypeId(String description) {
      for (RailwayDeviceType deviceType : RailwayDeviceType.values()) {
        if (deviceType.getDescription().equals(description)) {
          return deviceType;
        }
      }
      return null;
    }

    public Integer getType() {
      return type;
    }

    public String getDescription() {
      return description;
    }

    public Integer getRailDeviceTypeId() {
      return railDeviceTypeId;
    }

  }
}
